<template>
	<div class="tmp">
		
		<div class="div">
			<ul>
				<li @click="unadd">-</li>
				<li>{{obj.num}}</li>
				<li  @click="add">+</li>
			</ul>
			
		</div>
		
	</div>
</template>



<script>
	export default {

	  data () {
	    return {
	    	
	    	obj:{
	    		type:"add",
	    		id:0,
	    		num:0
	    	}
	    }
	 },
	 created(){
	 	this.obj.num = this.number || 1;
	 	this.obj.id = this.ids || 0
	 },
	 methods:{
	 	add(){
	 		this.obj.type="add"
	 		this.obj.num++
	 		this.tofather()
	 	},
	 	unadd(){
	 		if(this.obj.num <= 1) { return}
	 		this.obj.type="unadd"
	 		this.obj.num--
	 		this.tofather()
	 	},
	 	tofather(){
	 		this.$emit("num",this.obj)//向父组件传值
	 	}
	 	
	 	
	 }
	 ,
	  props:['number',"ids"]  //这个数据是从父组件传入进来的
	}
		
	
	
	
</script>


<style scoped>
		.div ul{
			display: flex;
		}
		.div ul li{
			list-style: none;
			width: 30px;
			height: 30px;
			border: 1px solid #ccc;
			text-align: center;
			line-height: 30px;
		}


</style>